using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.Position;

namespace TrainingManagement.api.Models.BusinessLogic.Position
{
    public class PositionUpdateOperation : BusinessOperation<BusinessObjects.Position, bool>
    {
        readonly PositionUpdateDataSource _positionUpdate = new PositionUpdateDataSource();

        public override bool Run(BusinessObjects.Position input)
        {
            if (_positionUpdate.Execute(input))
                return true;
            throw new Exception(string.Format("{0} was not updated!", input.Title));
        }
    }
}